package cn.bdqn.pn.controller.user;

import cn.bdqn.pn.pojo.user.Resource;
import cn.bdqn.pn.pojo.user.Role;
import cn.bdqn.pn.pojo.user.RoleResource;
import cn.bdqn.pn.service.user.role_ResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping(value = "/role_Resource")
public class role_ResourceController {
    @Autowired
    private role_ResourceService role_resourceService;
    @RequestMapping(value = "/addrole_Resourc")
    public String toAdd(RoleResource role_resource){
        return "addrole_Resource";
    }

   @RequestMapping("/add")
    public String add(Integer roleId,Integer resourceId) {
       System.out.println("=====================roleId="+roleId);
       System.out.println("=====================resourceId="+resourceId);
        RoleResource role_resource=new RoleResource();
       Role role=new Role();
       role.setRoleId(roleId);
        role_resource.setRole(role);
       Resource resource=new Resource();
       resource.setResourceid(resourceId);
        role_resource.setResource(resource);
        role_resourceService.addRoleResource(role_resource);
        return "redirect:addrole_Resourc";
    }
}
